package com.neusoft.lohas.modules.ivm.entity.product;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.neusoft.lohas.common.persistence.IdEntity;
import com.neusoft.lohas.modules.ivm.entity.merchant.Merchant;
import com.neusoft.lohas.modules.sys.entity.User;

/**
 * 商品评论Entity
 * 
 * @author Jackie.Liu
 * @version 2014-12-16
 */
@Entity
@Table(name = "ivm_comment")
@DynamicInsert
@DynamicUpdate
public class Comment extends IdEntity<Comment> {

	private static final long serialVersionUID = 1L;
	private Merchant merchant; // 所属商户
	private Product product; // 所属商品
	private User user; // 所属用户
	private int level; // 评论等级(1:非常满意,2:满意,3:一般,4:不满意,5:非常不满意)
	private String content; // 评论内容

	public Comment() {
		super();
	}

	public Comment(String id) {
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="merchant_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="归属商户不能为空")
	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	@ManyToOne
	@JoinColumn(name = "product_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="所属商品不能为空")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne
	@JoinColumn(name = "user_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="所属用户不能为空")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

}
